<h1 class="text-center" translate="ADMIN.USER_SEARCH"></h1>

<table class="table table-striped">
	<tr>
		<td class="tdBold alignMiddle" translate="TORRENTS.USERNAME"></td>
		<td>
			<input type="text" class="form-control" placeholder="{{ 'TORRENTS.USERNAME' | translate }}" ng-model="vm.search.name" ng-model-options="{ debounce: 500 }" ng-change="vm.doSearch()" />
		</td>
		<td class="tdBold alignMiddle" translate="ADMIN.IP"></td>
		<td>
			<input type="text" class="form-control" placeholder="{{ 'ADMIN.IP' | translate }}" ng-model="vm.search.ip" ng-model-options="{ debounce: 500 }" ng-change="vm.doSearch()" />
		</td>
	</tr>
	<tr>
		<td class="tdBold alignMiddle" translate="SIGNUP.EMAIL"></td>
		<td>
			<input type="text" class="form-control" placeholder="{{ 'SIGNUP.EMAIL' | translate }}" ng-model="vm.search.email" ng-model-options="{ debounce: 500 }" ng-change="vm.doSearch()" />
		</td>
		<td class="tdBold alignMiddle">&nbsp;</td>
		<td>
			&nbsp;
		</td>
	</tr>
</table>

<br />

<loading-indicator hide="vm.users"></loading-indicator>

<table class="table table-nowrap" ng-show="vm.users">
	<tr>
		<th style="width: 200px;" class="text-left" translate="TORRENTS.NAME"></th>
		<th class="text-left" translate="STATUS.RATIO"></th>
		<th class="text-left" translate="ADMIN.IP"></th>
		<th class="text-left" translate="SIGNUP.EMAIL"></th>
		<th class="text-left" translate="LIST.CREATED"></th>
		<th class="text-left" translate="FRIENDS.LAST_SEEN"></th>
	</tr>
	<tr ng-repeat="user in vm.users track by user.id">
		<td><user user="::user"></user></td>
		<td ng-bind-html="::user.uploaded/user.downloaded | ratio"></td>
		<td><a href="" ng-click="vm.searchForIp(user.ip);"><span ng-bind-html="user.ip | highlight:vm.search.ip"></span></a></td>
		<td ng-bind-html="user.email | highlight:vm.search.email"></td>
		<td>{{ ::user.added }}</td>
		<td>{{ ::user.last_access }}</td>
	</tr>
</table>

<div class="text-center">
	<uib-pagination max-size="10" items-per-page="vm.itemsPerPage" total-items="vm.totalItems" ng-model="vm.currentPage" ng-click="vm.loadUsers()" previous-text="{{ 'PAGER.PREVIOUS' | translate }}" next-text="{{ 'PAGER.NEXT' | translate }}" boundary-links="true" first-text="{{ 'PAGER.FIRST' | translate }}" last-text="{{ 'PAGER.LAST' | translate }}"></uib-pagination>
</div>

<div class="col-lg-10 col-lg-push-1" ng-show="vm.loginAttempts.length > 0">
	<h2 class="text-center" translate="ADMIN.LOGIN_ATTEMPTS"></h2>
	<table class="table text-left">
		<tr>
			<th class="text-left" translate="TORRENTS.DATE"></th>
			<th class="text-left" translate="ADMIN.IP"></th>
			<th class="text-left" translate="TORRENTS.USERNAME"></th>
			<th class="text-left" translate="SIGNUP.PASSWORD"></th>
		</tr>
		<tr ng-repeat="login in vm.loginAttempts track by login.id">
			<td>{{ ::login.added }}</td>
			<td><a href="" ng-click="vm.searchForIp(login.ip);"><span ng-bind-html="login.ip | highlight:vm.search.ip"></span></a></td>
			<td>
				<user ng-if="::login.user.id" user="login.user"></user>
				<span ng-if="::!login.user.id">{{ login.name }} ?</span>
			</td>
			<td>{{ ::login.password }}</td>
		</tr>
	</table>
</div>

<div class="clearfix"></div>
<br />

<div class="col-lg-10 col-lg-push-1" ng-show="vm.iplog.length > 0">
	<h2 class="text-center" translate="ADMIN.IP_LOG"></h2>
	<table class="table text-left">
		<tr>
			<th class="text-left" translate="TORRENTS.USER"></th>
			<th class="text-left" translate="ADMIN.IP"></th>
			<th class="text-left" translate="ADMIN.HOSTNAME"></th>
			<th class="text-left" translate="FRIENDS.LAST_SEEN"></th>
		</tr>
		<tr ng-repeat="log in vm.iplog">
			<td><user user="::log"></user></td>
			<td><a href="" ng-click="vm.searchForIp(log.ip);"><span ng-bind-html="log.ip | highlight:vm.search.ip"></span></a></td>
			<td>{{ ::log.host }}</td>
			<td>{{ ::log.lastseen }}</td>
		</tr>
	</table>
</div>

<div class="col-lg-10 col-lg-push-1" ng-show="vm.recoveryLog.length > 0">
	<h2 class="text-center" translate="ADMIN.RECOVERY_LOG"></h2>
	<table class="table text-left">
		<tr>
			<th class="text-left" translate="TORRENTS.USER"></th>
			<th class="text-left" translate="ADMIN.IP"></th>
			<th class="text-left" translate="SIGNUP.EMAIL"></th>
			<th class="text-left" translate="TORRENTS.DATE"></th>
		</tr>
		<tr ng-repeat="log in vm.recoveryLog">
			<td><user user="::log"></user></td>
			<td><a href="" ng-click="vm.searchForIp(log.ip);"><span ng-bind-html="log.ip | highlight:vm.search.ip"></span></a></td>
			<td ng-bind-html="log.email"></td>
			<td>{{ ::log.date }}</td>
		</tr>
	</table>
</div>

<div class="col-lg-10 col-lg-push-1" ng-show="vm.emailLog.length > 0">
	<h2 class="text-center" translate="ADMIN.EMAIL_LOG"></h2>
	<table class="table text-left">
		<tr>
			<th class="text-left" translate="TORRENTS.USER"></th>
			<th class="text-left" translate="ADMIN.IP"></th>
			<th class="text-left" translate="SIGNUP.EMAIL"></th>
			<th class="text-left" translate="TORRENTS.DATE"></th>
		</tr>
		<tr ng-repeat="log in vm.emailLog">
			<td><user user="::log"></user></td>
			<td><a href="" ng-click="vm.searchForIp(log.ip);"><span ng-bind-html="log.ip | highlight:vm.search.ip"></span></a></td>
			<td ng-bind-html="log.email"></td>
			<td>{{ ::log.datum }}</td>
		</tr>
	</table>
</div>

<div class="clearfix"></div>
